<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>欢迎使用网上商城</title>
    <link rel="icon" th:href="@{/favicon.ico}" type="image/x-icon"/>
    <link rel="bookmark" th:href="@{/favicon.ico}" type="image/x-icon"/>
    <script src="../../../static/js/jquery/jquery-3.6.0.min.js" th:src="@{/js/jquery/jquery-3.6.0.min.js}"></script>
    <script src="../../../static/js/bootstrap/bootstrap.bundle.js"
            th:src="@{/js/bootstrap/bootstrap.bundle.js}"></script>
    <link rel="stylesheet" href="../../../static/css/bootstrap/bootstrap.css"
          th:href="@{/css/bootstrap/bootstrap.css}">
</head>
<body>
<div class="container">
    <h2>所有的图书</h2>
    <div class="divider">
        <hr/>
    </div>
    <table class="table table-bordered">
        <thead>
        <tr class="active">
            <th>封面</th>
            <th>图书名称</th>
            <th>作者</th>
            <th>售价</th>
            <th>库存</th>
            <th>销量</th>
            <th colspan="2">操作</th>
        </tr>
        </thead>
        <tbody th:each="">
        <tr>
            <td><img style="width: 50px; height: 50px;" src="${pageContext.request.contextPath}${book.imagepath}"></td>
            <!-- <td>${category.name}</td> -->
            <%-- 判断够不够10个，不够10个，直接显示，够10个显示前面10个加。。。 --%>
            <td>
                <a href="${pageContext.request.contextPath }/client/BookServlet?method=showBook&bookid=${book.id }">
                    ${fn:substring(book.name, 0, 10)}${fn:length(book.name)>10? '...': '' }
                </a>
            </td>
            <td>${book.author }</td>
            <td>${book.price }</td>
            <td>${book.storenumber }本</td>
            <td>${book.salesamount }本</td>
            <td>
                <button class="updateBtn btn btn-info btn-block btn-lg"
                        onclick="location.href='${pageContext.request.contextPath}/manager/BookServlet?method=toUpdateUI&bookid=${book.id}'">
                    修改
                </button>
            </td>
            <td>
                <button class="deleteBtn btn btn-danger btn-block btn-lg" name="${book.name }" id="${book.id}">删除
                </button>
            </td>
        </tr>
        </tbody>
    </table>
</div>
</body>
</html>